<?php


/*
 * Created on 18/10/2008
 *
 * This class represents a position purchased after a match 
 */

class MatchPositionPurchase {
    var $position;
    var $rosterNum;
    var $name;
    var $cost;

    function init($row, & $race) {
        $i = 0;
        $this->position = $race->getPositionById($row[$i++]);
        $this->rosterNum = $row[$i++];
        $this->name = $row[$i++];
        if ($this->position) {
            $this->cost = $this->position->cost;
            if ($this->position->isJourneyman() or $this->position->isStar()) {
                $this->cost = 0;
            }
        } else {
            $this->position = "Unknown";
        }
    }
    
    /**
     * Checks to see if this player could be the one bought from this purchase. If the player has been developed 
     * or changed it won't work
     */
    function isSameAs(& $player) {
        $rc = false;
        if (0 != strcmp($this->position->position, $player->position)) {
            return false;
        }
        if ($player->cost != $this->cost) {
            return false;
        }
        if (0 != strcmp($player->name, $this->name)) {
            return false;
        }
        if ($player->rosterNum != $this->rosterNum) {
            return false;
        }
        return true;
    }
}
?>
